home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / Speech Demo.sit / Speech Demo.c < prev    next >
C/C++ Source or Header  |  1993-08-11  |  2KB  |  67 lines

  1. /*    Quick & dirty example of using the new Speech Manager                */
  2. /*    Created August 11, 1993 by Alan Coopersmith                            */
  3. /*     (Internet: alanc@soda.berkeley.edu)                                */
  4. /*   (US Mail: 2097 Eastwood Blvd., Ogden, UT 84403                        */
  5. /*                                                                        */
  6. /*  Since this isn't really worth copyrighting I hereby release this     */
  7. /*  source code into the public domain.  Enjoy!                            */
  8. /*                                                                        */
  9. /*    Known bugs:                                                            */
  10. /*     - doesn't bother checking if the speech manager is installed        */
  11. /*   - never checks if the Speech functions return errors                */
  12. /*                                                                        */
  13. /*  This was developed using Symantec's Think C 5.04                    */
  14.  
  15. /* <Speech.h> is available for anonymous ftp from ftp.apple.com in        */
  16. /* the directory dts/mac/sys.soft/speech as part of the Speech Manager    */
  17. #include <Speech.h>        
  18.  
  19. #include <ToolUtils.h>        /* GetString()    */
  20. #include <OSUtils.h>        /* Delay()        */
  21. #include <Memory.h>            /* HLockHi()    */
  22.  
  23. #define        DEFAULT_TEXT        "Testing. 1. 2. 3."
  24. #define        DEFAULT_TEXT_LEN     17
  25.  
  26. main()
  27. {
  28.     short            voiceCount;
  29.     short            counter;
  30.     SpeechChannel    theChannel;
  31.     VoiceSpec        theVoice;
  32.     char            defaultText[]         = DEFAULT_TEXT;
  33.     char            *theTextToBeSpoken;
  34.     long            textlen;
  35.     long            delayLen;
  36.     OSErr            myErr;
  37.     StringHandle    theHand;
  38.     
  39.     theHand    = GetString(128);
  40.     
  41.     if (theHand == nil)
  42.     {
  43.         theTextToBeSpoken    = defaultText;
  44.         textlen                = DEFAULT_TEXT_LEN;
  45.     }
  46.     else
  47.     {
  48.         HLockHi                ((Handle) theHand);
  49.         theTextToBeSpoken    = (char *) (*theHand) + 1;
  50.         textlen                = (long) **theHand;
  51.     }
  52.     
  53.     
  54.     myErr = CountVoices    (&voiceCount);
  55.  
  56.     for (counter = 1; counter <= voiceCount; counter++)
  57.     {
  58.         myErr = GetIndVoice          (counter, &theVoice);
  59.         myErr = NewSpeechChannel     (&theVoice, &theChannel);
  60.         myErr = SpeakText              (theChannel, (Ptr) theTextToBeSpoken, textlen);
  61.         
  62.         while    (SpeechBusy())
  63.             Delay(60, &delayLen);
  64.         
  65.         myErr = DisposeSpeechChannel (theChannel);
  66.     }
  67. }